<?php
namespace app\demo\enum;

final class State{

    const NORMAL=11;

    const RECYLE_BIN=22;

    const DELETED=33;

    public static function options(){
        $options=[
            self::NORMAL=>"正常",
            self::RECYLE_BIN=>"回收站",
            self::DELETED=>"已删除",
        ];
        return $options;
    }

    public static function code($text='',$default=''){
        $options=self::options();
        $code=array_search($text,$options);
        return $code==false?$default:$code;
    }

    public static function codes(){
        return array_keys(self::options());
    }

    public static function text($code='',$default=''){
        $options=self::options();
        return isset($options[$code])?$options[$code]:$default;
    }

    public static function texts(){
        return array_values(self::options());
    }

    public static function tabs(){
        $options=self::options();
        unset($options[self::DELETED]);
        return $options;
    }

}